<extend name="Layout:layout_list" />
<block name="body_content_block">
    <table id="main_grid" class="easyui-datagrid" data-url="{:AddonU('Statics/get_daybill_list_json')}"></table>
    <div id="tb" style="padding:2px 5px;">
        <div style="margin-bottom: 5px; border-bottom:solid 1px #dddddd;">
            <a href="#" class="easyui-linkbutton lnk_grid_search" iconCls="icon-search" plain="true">搜索</a>
        </div>
    </div>
    <!--隐藏区域-->
    <div style="display:none">
        <!--表格查询对话框-->
        <div id="dlg_search" style="padding:10px">
            <form method="get" action="{:AddonU('Statics/get_daybill_list_json')}" data-export-url="{:AddonU('Statics/daybill_export')}">
                <input type="text" name="beginDate" class="easyui-datebox" value="{$search.beginDate}"/> 至
                <input type="text" name="endDate" class="easyui-datebox" value="{$search.endDate}"/>
                <if condition="$isSuperAdmin">
                    用户名：<input type="text" name="siteID" id="siteID" class="easyui-combobox" data-url="{:AddonU('Admin/get_admin_json')}" />
                    <else/>
                    <input type="hidden" name="siteID" value="{$loginData.siteID}"/>
                </if>
            </form>
        </div>
        <!--/表格查询对话框-->
    </div>
    <!--/隐藏区域-->
</block>
<block name="body_after_block">
    <script type="text/javascript">
        // 页面初始化
        var curd_grid = CurdGrid.newInstance();
        curd_grid.before_search_dialog = function () {
            $('#siteID').combobox({url: $('#siteID').data('url'), valueField: 'id', textField: 'text'});
        }
        curd_grid.config({
            title: '日结账单管理',
            toolbar: '#tb',
            fitColumns: true,
            showFooter: true,
            columns: [[
                    {field: 'ck', checkbox: true},
                    {title: "租户ID", field: "siteID", sortable: true, formatter: function (value, row) {
                            if (value) {
                                return row.userName + '[' + value + ']';
                            }
                        }},
                    {title: "日期", field: "billdate", sortable: true},
                    {title: "外呼", field: "outAmount"},
                    {title: "转座席", field: "inAmount", sortable: true},
                    {title: "短信", field: "smsAmount", sortable: true},
                    {title: "合计", field: "subtotal", sortable: true},
                    {title: "充值", field: "rechargeAmount", sortable: true},
                    {title: "可透支金额", field: "allowOverdraftAmount", sortable: true},
                    {title: "余额", field: "blance", sortable: true},
                    {title: "编号", field: "id", hidden: true},
                ]],
            rowStyler: function (i, row) {
                if (row.blance < 0) {
                    return 'background-color:#d1dee6';
                }
            },
        });
        curd_grid.init();

    </script>
</block>